package br.org.credfaz.sis.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import br.org.credfaz.sis.MysqlConnectionFactory;
import br.org.credfaz.sis.modelo.TelefoneCliente;

public class TelefoneClienteDAO {
	
private final Connection connection;
	
	public TelefoneClienteDAO(){
		try{
			connection = new MysqlConnectionFactory().getConnection();
		}catch (SQLException e){
			throw new RuntimeException(e);
		}
	}
	
	public void adiciona(TelefoneCliente telefonecliente){
		String sql = "insert into telefonecliente (idtelefonecliente, idcliente, codtipotelefone," +
				"numddd, numtelefone, numramal) values (?, ?, ?, ?, ?, ?)";
		PreparedStatement stmt;
		try{
			stmt = connection.prepareStatement(sql);
			
			stmt.setInt(1, telefonecliente.getIdtelefonecliente());
			stmt.setLong(2, telefonecliente.getIdcliente());
			stmt.setInt(3, telefonecliente.getCodtipotelefone());
			stmt.setString(4, telefonecliente.getNumddd());
			stmt.setString(5, telefonecliente.getNumtelefone());
			stmt.setString(6, telefonecliente.getNumramal());
					
			
			stmt.execute();
			
		}catch (SQLException e){
			throw new RuntimeException(e);
		}
	}

}
